package com.ymatou.iapi.productprice.testcase;

import java.util.Arrays;
import java.util.Date;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.productprice.parameter.PriceConfig;
import com.ymatou.iapi.productprice.parameter.PriceForSearch;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.productprice.parameter.ProductPriceBean;
import com.ymatou.iapi.productprice.service.GetPriceByProdIdsTradeIsolationForSearchedListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AdminCallService;
import com.ymttest.business.service.ProductPriceCallService;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductTimeStampWapper;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.YMTDateUtil;

@Ignore
public class Ts_GetPriceByProdIdsTradeIsolationForSearchedList {
	private static int newBuyerId = ProductPriceCallService.getNewCustomer();
	private static int oldBuyerId = ProductPriceCallService.getOldCustomer();
	private static GetPriceByProdIdsTradeIsolationForSearchedListCall getPriceByProdIdsTradeIsolationForSearchedListCall = new GetPriceByProdIdsTradeIsolationForSearchedListCall();
	
	private static ProductTimeStampWapper productTimeStampWapper = new ProductTimeStampWapper();
	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
	
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("交易隔离查询接口, 提供搜索接口使用");
	}

	@Before
	public void caseUp() {
		
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getPriceByProdIdsTradeIsolationForSearchedListCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_001() {
		Logger.start(true, "非交易隔离,普通新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			
			//1 码头新客户 查询结果为活动价格
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为普通商品价格逻辑
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 2, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
				}else{
					PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 3, false);
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				}
				
				
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 3, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 2, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_002() {
		Logger.start(true, "非交易隔离,非新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			
			//1 码头新客户 查询结果为活动价格
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为活动价格
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				}else{
					PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 3, false);
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
					
					PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,3, true);
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
				}
				
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 3, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,3, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_003() {
		Logger.start(true, "交易隔离,新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
		
			//1 码头新客户 查询结果为活动价格
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为普通商品价格逻辑
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 2, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
				}else{
					PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 3, false);
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				}
				
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,3, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,2, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_004() {
		Logger.start(true, "交易隔离,非新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			
			//1 码头新客户 查询结果活动商品价格
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为活动商品价格
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));

				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				}else{
					PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 3, false);
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
					
					PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,3, true);
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
				}
				
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,3, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate,3, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_005() {
		Logger.start(true, "普通商品");
		try {
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId,0);
			
			//1 码头新客户 查询结果为普通商品价格逻辑
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 1, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为普通商品价格逻辑
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 2, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean);
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
				
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 1, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldProductPriceUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBeanUpdate, 2, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldProductPriceUpdate));
				
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_006() {
		Logger.start(true, "活动结束，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			
			//1 码头新客户 查询结果为活动价格
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为活动价格
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库活动商品结束时间，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1)));
				AdminCallService.closeProductInActivity(String.valueOf(inaid));
				
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				}else{
					PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,1, false);
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
					
					PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,2, true);
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
				}
				
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,1, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,2, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_007() {
		Logger.start(true, "活动库存清零，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			
			//1 码头新客户 查询结果为活动价格
			PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
			JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
			
			
			//2码头老客户查询结果为活动价格
			PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, true);
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
		
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库活动商品结束时间，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
				
				
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
				}else{
					PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,1, false);
					ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
					
					PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,2, true);
					ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
				}
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date())); 
				
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,1, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,2, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
			}
		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_008() {
		Logger.start(true, "删除时间戳表后，查询");
		try{
			if (PriceConfig.isCacheCheck){
				ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
				String productId = productAllPriceBean.getProductId();
				//删除时间戳表记录
				productTimeStampWapper.delete(productId);
				
				//1 码头新客户 查询结果为活动价格
				PriceForSearch newPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, false);
				JSONObject ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearch));
				
				
				//2码头老客户查询结果为活动价格
				PriceForSearch oldPriceForSearch = ProductPriceCallService.getPriceForSearch(productAllPriceBean, 3, true);
				JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearch));
			
				//修改mongo数据库活动库存
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
				
				YMTDateUtil.waitTime(5);
				//新客修改后价格检查
				PriceForSearch newPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,1, false);
				ret = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret, Arrays.asList(newPriceForSearchUpdate));
				
				//老客修改后价格检查
				PriceForSearch oldPriceForSearchUpdate = ProductPriceCallService.getPriceForSearch(productAllPriceBean,2, true);
				ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
				ProductPriceCallService.checkPriceForSearchList(ret2, Arrays.asList(oldPriceForSearchUpdate));
				
			}
		}catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdIdsTradeIsolationForSearchedList_009() {
		Logger.start(true, "非交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation_Member();
			String productId = productAllPriceBean.getProductId();
			
			int prodInActivityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			
			//新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,true);
			//新客 会员价
			ProductPriceBean priceIncludeActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			//老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,true);
			//老客 会员价
			ProductPriceBean priceIncludeActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			
			
			//会员政策1， 会员等级3以上才能享受活动价
			
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");
			//0级会员 新客 普通价
			JSONObject ret1 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret1, Arrays.asList(priceIgnoreActivity_NewCust));
			
			//6级会员  老客 会员活动价
			JSONObject ret2 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret2, Arrays.asList(priceIncludeActivity_OleCust));
			
			
			//会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2, "2015-01-02 00:00:00,2016-03-23 23:59:59");
			
			//新客 注册时间2015-05-26 14:20:04 会员活动价
			JSONObject ret3 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret3, Arrays.asList(priceIncludeActivity_NewCust));
			
			//老客 注册时间2016-04-22 10:19:05 普通价格
			JSONObject ret4 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret4,Arrays.asList( priceIgnoreActivity_OleCust));
			
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 3 
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "3");
			
			//新客  标签3  会员活动价
			JSONObject ret5 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret5, Arrays.asList(priceIncludeActivity_NewCust));
			
			//老客 没标签 普通价格
			JSONObject ret6 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(oldBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret6, Arrays.asList(priceIgnoreActivity_OleCust));
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 4
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "4");
			
			//新客  标签3  普通价
			JSONObject ret7 = getPriceByProdIdsTradeIsolationForSearchedListCall.callAndGetReturnData(newBuyerId, Arrays.asList(productId));
			ProductPriceCallService.checkPriceList(ret7, Arrays.asList(priceIgnoreActivity_NewCust));
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}
